function getTurnoverInputValue() {
  const turnoveInput = document.querySelector(
    ".mantine-fxox9l > .mantine-175jfpf > input"
  );
  console.log(turnoveInput, "turnoveInput");
  if (turnoveInput) {
    const turnoverValue = turnoveInput.value;
    console.log(turnoverValue, "turnoverValue");
    return turnoverValue;
  } else {
    console.log("未找到.mantine-fxox9l > .mantine-175jfpf > input的元素");
  }
  return null;
}

import { getSliderValue } from "./displayInfor.js";
export function marketBuyOrSell() {
  let turnoverValue = getTurnoverInputValue();
  let sliderValue = getSliderValue();
  console.log(turnoverValue, sliderValue);
  const btn = document.querySelector(".trading_sub > .mantine-1v71nuo");
  console.log(btn, "btn");
  if (btn) {
    const originalHandler = btn.onclick;
    if (originalHandler) {
      btn.onclick = null;
    }
    btn.addEventListener("click", async (event) => {
      console.log("买入按钮被点击");
      event.preventDefault();
      console.log("执行自定义逻辑");
      // chrome.runtime.sendMessage(
      //   {
      //     action: "interceptRequest",
      //     url: "https://www.gate.io/apiw/v2/unified/futures/usdt/contracts",
      //   },
      //   (response) => {
      //     if (chrome.runtime.lastError) {
      //       console.error("消息发送失败：", chrome.runtime.lastError.message);
      //     } else {
      //       console.log("收到响应：", response);
      //     }
      //   }
      // );
    });
  } else {
    console.log("未找到.trading_sub > .mantine-1v71nuo买入按钮节点");
  }
}
